.tree {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;

  .tree__item & {
    padding-left: 8px;
    margin-top: 6px;
  }
}

.tree__item {
  @extend %first-last-no-margin;

  position: relative;
  margin: 4px 0;
  border-radius: 3px;

  &.active {
    background-color: $color-primary-100;
  }

  &.tree__item--loading::after {
    content: " ";

    @include loading(14px);
    @include absolute(9px, 9px, auto, auto);
  }
}

%tree__size {
  line-height: 32px;
  height: 32px;
}

.tree__action {
  @extend %tree__size;

  padding: 0 6px;
  border-radius: 3px;

  &:not(.tree__action--disabled):hover {
    background-color: $color-neutral-100;
  }

  .tree__item.active &:hover {
    background-color: transparent;
  }

  &.tree__action--has-options,
  &.tree__action--has-right-icon {
    padding-right: 32px;
  }
}

.tree__link {
  @extend %tree__size;
  @extend %ellipsis;

  display: block;
  color: $color-primary-900;
  font-size: 14px;

  &:hover {
    text-decoration: none;
  }

  &.tree__link--group {
    font-weight: 600;
  }

  .tree__action--disabled &:hover {
    cursor: inherit;
  }
}

.tree__icon {
  @extend %tree__size;

  text-align: center;
  width: $fa-fw-width;
  color: $color-neutral-700;
  margin-right: 4px;
  font-size: 11px;

  &.tree__icon--type {
    color: $color-neutral-300;
  }
}

%tree_sub-size {
  line-height: 28px;
  height: 28px;
}

.tree__subs {
  list-style: none;
  padding: 0 0 2px 0;
  margin: 0;
}

.tree__sub {
  @extend %tree_sub-size;

  position: relative;
  padding: 0 34px;

  &::before,
  &::after {
    content: "";
    position: absolute;
    left: 12px;
  }

  &::before {
    top: 0;
    height: 28px;
    border-left: 1px solid $color-neutral-200;
  }

  &::after {
    top: 14px;
    width: 12px;
    border-bottom: 1px solid $color-neutral-200;
  }

  &:last-child::before {
    height: 15px;
  }
}

.tree__sub-link {
  @extend %tree_sub-size;
  @extend %ellipsis;

  color: $color-primary-900;
  display: block;

  &:hover {
    text-decoration: none;
    color: $color-primary-500;
  }

  .active > & {
    font-weight: 600;
    color: $color-primary-600;
  }
}

.tree__sub-add {
  display: inline-block;
  margin: 0 0 10px 10px;
  font-size: 12px;
  color: $color-neutral-300;

  &:hover {
    text-decoration: none;
    color: $color-neutral-500;
  }
}

.tree__right-icon {
  display: none;
  position: absolute;
  z-index: 1;
  right: 0;
  top: 0;
  text-align: center;
  width: 32px;
  color: $color-neutral-700;
  height: inherit;
  line-height: inherit;

  :hover > & {
    display: block;
  }

  .tree__item--loading > .tree__action > & {
    display: none;
  }
}

.tree__options {
  @extend .tree__right-icon;

  color: $color-neutral-300;

  &:hover {
    color: $color-neutral-700;
  }
}
